home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / netlib / printuserfault.c < prev    next >
C/C++ Source or Header  |  1994-03-29  |  2KB  |  72 lines

  1. RCS_ID_C="$Id: printuserfault.c,v 3.1 1994/03/29 12:56:35 ppessi Exp $";
  2. /* 
  3.  * printuserfault.c --- Print a usergroup error message (DOS)
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  8.  *                  Helsinki University of Technology, Finland.
  9.  *                  All rights reserved.
  10.  *
  11.  * Created      : Sat Mar 20 02:10:14 1993 ppessi
  12.  * Last modified: Mon Mar 28 02:26:31 1994 ppessi
  13.  */
  14.  
  15. /****** net.lib/PrintUserFault ************************************************
  16.  
  17.     NAME
  18.         PrintUserFault - socket error messages
  19.  
  20.     SYNOPSIS
  21.         PrintUserFault(code, banner)
  22.         void PrintUserFault(LONG, const UBYTE *)
  23.  
  24.     FUNCTION
  25.         The PrintUserFault() function finds the error message corresponding to
  26.         the code and writes it, followed by a newline, to the standard error
  27.         or Output() filehandle. If the argument string is non-NULL it is
  28.         preappended to the message string and separated from it by a colon and
  29.         space (`: '). If string is NULL only the error message string is
  30.         printed.
  31.  
  32.     NOTES
  33.         The PrintUserFault() function used the DOS io functions.  It is
  34.         recommended to use PrintUserFault() when the standard C IO functions
  35.         are not otherwise in use.
  36.  
  37.     SEE ALSO
  38.         strerror(), perror(), <netinclude:sys/errno.h>
  39.  
  40. ******************************************************************************
  41. */
  42.  
  43. #include <errno.h>
  44.  
  45. #include <exec/execbase.h>
  46. extern struct ExecBase *SysBase;
  47.  
  48. #include <dos/dos.h>
  49. #include <dos/dosextens.h>
  50.  
  51. #if __SASC
  52. #include <proto/dos.h>
  53. #include <proto/usergroup.h>
  54. #elif __GNUC__
  55. #include <inline/dos.h>
  56. #endif
  57.  
  58. void PrintUserFault(LONG code, const UBYTE *banner)
  59. {
  60.   struct Process *p = (struct Process *)SysBase->ThisTask;
  61.   BPTR Stderr = p->pr_CES ? p->pr_CES : p->pr_COS;
  62.  
  63.   if (banner != NULL) {
  64.     FPuts(Stderr, banner);
  65.     FPuts(Stderr, ": ");
  66.   }
  67.   FPuts(Stderr, ug_StrError(code));
  68.   FPuts(Stderr, "\n");
  69.   Flush(Stderr);
  70. }
  71.  
  72.